//
//  UUIDManager.m
//  myTest
//
//  Created by DuanLihang on 2017/12/8.
//  Copyright © 2017年 Duan. All rights reserved.
//

#import "UUIDManager.h"
#import "KeyChainManager.h"


static NSString * const KEY_IN_KEYCHAIN = @"com.duangongzi.uuid";


@implementation UUIDManager


+(void)saveUUID:(NSString *)uuid
{
    if (uuid && uuid.length > 0) {
        [KeyChainManager save:KEY_IN_KEYCHAIN data:uuid];
    }
}

+(NSString *)getUUID
{
    NSString *uuid = [KeyChainManager load:KEY_IN_KEYCHAIN];
    if (!uuid || uuid.length == 0) {
        uuid = [[NSUUID UUID] UUIDString];
        [self saveUUID:uuid];
    }
    return uuid;
}

+(void)deleteUUID
{
    [KeyChainManager delete:KEY_IN_KEYCHAIN];
}

@end
